package com.inossem.warehousestorage_inossem.activity.out_storage;

import com.inossem.warehousestorage_inossem.activity.base.BaseActivity;


//验收入库
public class OutStoragePickingDetailActivity extends BaseActivity {

//    private TextView title;
//
//    private PullToRefreshLayout refresh;
//
//    private PullableListView pickingOutStorageDetailList;
//
//    private PickingOutStorageDetailListAdapter adapter;
//
//    private String mSerial, mBatchNumber, materielCode, mRetainDecimal;
//
//    private OutStoragePickingOverviewBean.BodyBean.ItemListBean mMaterielDetail;
//
//
//    @Override
//    protected void onCreateImpl(Bundle savedInstanceState) {
//        setContentView(R.layout.activity_out_storage_picking_detail);
//        initView(OutStoragePickingDetailActivity.this);
//    }
//
//    @Override
//    protected void onResumeImpl() {
//        initData(OutStoragePickingDetailActivity.this);
//    }
//
//    private void initView(Activity activity) {
//        title = (TextView) activity.findViewById(R.id.headerTitle);
//        pickingOutStorageDetailList = (PullableListView) activity.findViewById(R.id.pickingOutStorageDetailList);
//        refresh = (PullToRefreshLayout) activity.findViewById(R.id.pickingOutStorageDetailRefresh);
//    }
//
//    private void initData(Activity activity) {
//        title.setText(getResources().getString(R.string.activity_out_storage_picking_detail_acquisition_of_subsidiary));
//        ActivityUtils.initBackAndFunction(activity, getResources().getString(R.string.activity_out_storage_picking_add_operator_an_overview_of_the_acquisition), new NoDoubleClickListener() {
//            @Override
//            public void onNoDoubleClick(View v) {
//                String message = check(activity);
//                if (message != null) {
//                    DialogUtils.getConfirmDialog(OutStoragePickingDetailActivity.this, message, new DialogUtils.ConfirmDialogListener() {
//                        @Override
//                        public void onConfirm(Dialog dialog) {
//                            OutStoragePickingDetailActivity.this.finish();
//                        }
//                    }).show();
//                } else {
//                    updateInfo(OutStoragePickingDetailActivity.this);
//                    OutStoragePickingDetailActivity.this.finish();
//                }
//            }
//        });
//
//        pickingOutStorageDetailList.setPullUpFlag(false);
//        pickingOutStorageDetailList.setPullDownFlag(false);
//        mBatchNumber = "";
//        getExtra(activity);
//        getData(activity);
//        setmScanListener((String scanResult, int length) -> {
//            String type = QRCodeUtils.getQRCodeType(scanResult);
//            switch (type) {
//                case QRCodeConstant.TYPE_BATCH:
//                    adapter.addBatchRequest(activity, false, null, QRCodeUtils.DecryptQRCode(scanResult, QRCodeConstant.PARAMETER_BATCH_NUMBER));
//                    break;
//                case QRCodeConstant.TYPE_POSITION:
//                    adapter.addBatchRequest(activity, false, null, QRCodeUtils.DecryptQRCode(scanResult));
//                    break;
//            }
//        }, QRCodeConstant.TYPE_BATCH, QRCodeConstant.TYPE_POSITION);
//    }
//
//    private void getExtra(Activity activity) {
//        mSerial = activity.getIntent().getStringExtra(OutStorageExtra.SERIAL);
////        mPickingClassify = activity.getIntent().getStringExtra(OutStorageExtra.PICKING_CLASSIFY);
////        mUseDepartment = activity.getIntent().getStringExtra(OutStorageExtra.USE_DEPARTMENT);
//    }
//
//    private void addOutStoragePickingItemListData(Context context, OutStoragePickingOverviewBean.BodyBean.ItemListBean materielDetail, List<BatchBean.BatchInfoBean> batchList, String batchNumber, ListView listView) {
//        adapter = new PickingOutStorageDetailListAdapter(context, materielDetail, batchList, batchNumber, new OutStorageDetailListener() {
//
//            @Override
//            public void getDefaultBatch(String number) {
//                GetDefaultBatchRequest.request(context, mMaterielDetail.getMat_id(), number, mMaterielDetail.getFty_id(), mMaterielDetail.getLocation_id(), null, TypeEnum.OUT_STORAGE_PICKING, new GsonBeanListener<BatchBean>() {
//                    @Override
//                    public void onSuccess(BatchBean bean) {
//                        addOutStoragePickingItemListData(context, mMaterielDetail, bean.getBody(), "", pickingOutStorageDetailList);
//                    }
//                });
//            }
//
//            @Override
//            public void selectItem(int position) {
//                pickingOutStorageDetailList.setSelection(position);
//            }
//
//            @Override
//            public void calculator() {
//                getCalculator(OutStoragePickingDetailActivity.this);
//            }
//        });
//        listView.setAdapter(adapter);
//    }
//
//    private void getCalculator(Context context) {
//        OutStorageCalculatorRequest.request(context, materielCode, new GsonBeanListener<OutStorageCalculatorBean>() {
//            @Override
//            public void onSuccess(OutStorageCalculatorBean bean) {
//                if (bean.getData().getFlag().equals("0")) {
//                    Toast.makeText(context, getResources().getString(R.string.activity_out_storage_allocating_detail_can_not_use_calculator), Toast.LENGTH_SHORT).show();
//                } else {
//                    DialogUtils.getCalculatorDialog(context, bean).show();
//                }
//
//            }
//        });
//    }
//
//    private void getData(Context context) {
//        mMaterielDetail = OutStorageUtils.getPickingOutStorageDetailBySerial(context, mSerial);
//        materielCode = mMaterielDetail.getMat_code();
//        mRetainDecimal = mMaterielDetail.getDecimal_place();
//        addOutStoragePickingItemListData(context, mMaterielDetail, mMaterielDetail.getBatchList(), mBatchNumber, pickingOutStorageDetailList);
//    }
//
//    @Override
//    public void onBackPressed() {
//        String message = check(OutStoragePickingDetailActivity.this);
//        if (message != null) {
//            DialogUtils.getConfirmDialog(OutStoragePickingDetailActivity.this, message, new DialogUtils.ConfirmDialogListener() {
//                @Override
//                public void onConfirm(Dialog dialog) {
//                    OutStoragePickingDetailActivity.super.onBackPressed();
//                }
//            }).show();
//        } else {
//            updateInfo(OutStoragePickingDetailActivity.this);
//            OutStoragePickingDetailActivity.super.onBackPressed();
//        }
//    }
//
//    private void updateInfo(Context context) {
//        mMaterielDetail.setBatchList(adapter.getmBatchList());
//        mMaterielDetail.setActualSendNumber(adapter.getmActualSendNumber());
//        OutStorageUtils.updatePickingOutStorageDetail(context, mMaterielDetail);
//    }
//
//    private String check(Context context) {
//        String message;
////        message = checkCount();
////        if (message != null) {
////            return message;
////        }
//        message = OutStorageUtils.checkConfirm(context,adapter.getmBatchList());
//        if (message != null) {
//            return message;
//        }
//        message = OutStorageUtils.checkNumber(context,adapter.getmBatchList());
//        if (message != null) {
//            return message;
//        }
//        message = OutStorageUtils.checkRetainDecimal(context,adapter.getmBatchList(),mRetainDecimal);
//        if (message != null) {
//            return message;
//        }
////        message = OutStorageUtils.checkCanSendNumber(context,adapter.getmActualSendNumber(),mMaterielDetail.getLast_qty());
////        if (message != null) {
////            return message;
////        }
//        return message;
//    }
//
////    private String checkCanSendNumber() {
////        if (!TextUtils.isEmpty(adapter.getmActualSendNumber())) {
////            Double actualSendNumberDou = Double.parseDouble(adapter.getmActualSendNumber());
////            Double canSendNumberDou = Double.parseDouble(mMaterielDetail.getLast_qty());
////            if (actualSendNumberDou > canSendNumberDou) {
////                return getResources().getString(R.string.activity_out_storage_sale_detail_forced_to_quit);
////            }
////        }
////        return null;
////    }
//
////    private String checkCount() {
////        if (adapter == null || adapter.getCount() <= 1) {
////            return "请添加记录\n是否强制退出?";
////        }
////        return null;
////    }
//
////    private String checkConfirm() {
////        int count = adapter.getCount() - 1;
////        for (int i = 0; i < count; i++) {
////            BatchBean.BatchInfoBean batchItem = (BatchBean.BatchInfoBean) adapter.getItem(i);
////            if (!PickingOutStorageDetailListAdapter.CONFIRM.equals(batchItem.getIsConfirm())) {
////                return getResources().getString(R.string.activity_in_storage_allocating_overview_control) + (i + 1) + getResources().getString(R.string.activity_out_storage_sale_detail_have_not_been_confirmed);
////            }
////        }
////        return null;
////    }
//
////    private String checkNumber() {
////        int count = adapter.getCount() - 1;
////        for (int i = 0; i < count; i++) {
////            BatchBean.BatchInfoBean batchItem = (BatchBean.BatchInfoBean) adapter.getItem(i);
//////            LogUtils.i("batchItem.getOutStorageNumber():" + batchItem.getOutStorageNumber());
////            if (TextUtils.isEmpty(batchItem.getQty()) || RegexUtils.checkZero(batchItem.getQty())) {
////                return getResources().getString(R.string.activity_in_storage_allocating_overview_control) + (i + 1) + getResources().getString(R.string.activity_out_storage_sale_detail_not_illegal);
////            }
////        }
////        return null;
////    }
//
////    private String checkRetainDecimal() {
////        int count = adapter.getCount() - 1;
////        for (int i = 0; i < count; i++) {
////            OutStoragePickingBatchListBean.DataBean.BatchListBean batchItem = (OutStoragePickingBatchListBean.DataBean.BatchListBean) adapter.getItem(i);
////            if (!TextUtils.isEmpty(batchItem.getOutStorageNumber()) && !Utils.checkRetainDecimal(batchItem.getOutStorageNumber(), mRetainDecimal)) {
//////            Utils.middleToast(context, context.getResources().getString(R.string.activity_in_storage_receive_overview_serial) + (i + 1) + );
////                return getResources().getString(R.string.activity_in_storage_receive_overview_serial) + (i + 1) + String.format(getResources().getString(R.string.common_retain_decimal_illegal), TextUtils.isEmpty(mRetainDecimal) ? getResources().getString(R.string.common_retain_decimal_unlimited) : mRetainDecimal);
////            }
////        }
////        return null;
////    }
}
